from datetime import datetime, timedelta
from celery_task import send_msg, send_email

# # 方法一
# v1 = datetime(2024, 2, 22, 15, 27, 00)
# print(v1)
# v2 = datetime.utcfromtimestamp(v1.timestamp())
# print(v2)
# result = send_msg.apply_async(args=['郑利城'], eta=v2)
# print(result.id)


# 方法二
ctime = datetime.now()
utc_time = datetime.utcfromtimestamp(ctime.timestamp())

time_delay = timedelta(seconds=10)  # 10秒后执行
task_time = utc_time + time_delay

# 没有eta参数，则是异步任务
result = send_msg.apply_async(args=['郑利城'], eta=task_time)
result2 = send_email.apply_async(args=['郑辛沛'], eta=task_time)
print(result.id)
print(result2.id)

